﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.UserInfo
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtUserName.Text.Trim().Length==0)
			{
				strErr+="UserName不能为空！\\n";	
			}
			if(this.txtUserPassword.Text.Trim().Length==0)
			{
				strErr+="UserPassword不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtGroupId.Text))
			{
				strErr+="GroupId格式错误！\\n";	
			}
			if(this.txtUserPhoneNum.Text.Trim().Length==0)
			{
				strErr+="UserPhoneNum不能为空！\\n";	
			}
			if(this.txtUserEmail.Text.Trim().Length==0)
			{
				strErr+="UserEmail不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUserRegTime.Text))
			{
				strErr+="UserRegTime格式错误！\\n";	
			}
			if(this.txtUserStatus.Text.Trim().Length==0)
			{
				strErr+="UserStatus不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string UserName=this.txtUserName.Text;
			string UserPassword=this.txtUserPassword.Text;
			int GroupId=int.Parse(this.txtGroupId.Text);
			string UserPhoneNum=this.txtUserPhoneNum.Text;
			string UserEmail=this.txtUserEmail.Text;
			DateTime UserRegTime=DateTime.Parse(this.txtUserRegTime.Text);
			string UserStatus=this.txtUserStatus.Text;

			Maticsoft.Model.UserInfo model=new Maticsoft.Model.UserInfo();
			model.UserName=UserName;
			model.UserPassword=UserPassword;
			model.GroupId=GroupId;
			model.UserPhoneNum=UserPhoneNum;
			model.UserEmail=UserEmail;
			model.UserRegTime=UserRegTime;
			model.UserStatus=UserStatus;

			Maticsoft.BLL.UserInfo bll=new Maticsoft.BLL.UserInfo();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
